﻿using Awsc.DataAcquisitionSys.Core.DataAcquisition;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Awsc.DataAcquisitionSys.Core.Common.Extensions
{
    public static class ObjectExtensions
    {
        public static double ToDouble(this SensorData obj)
        {
            if (obj == null || obj.Value == null)
            {
                return 0;
            }
            
            return Convert.ToDouble(obj.Value);
        }
        public static double ToInt(this SensorData obj)
        {
            if (obj == null || obj.Value == null)
            {
                return 0;
            }
            return Convert.ToInt32(obj);
        }

        public static bool ToBool(this SensorData obj)
        {
            if (obj == null || obj.Value == null)
            {
                return default;
            }
            return Convert.ToBoolean(obj.Value);
        }
    }
}
